package cn.ciis.ciis.test;

import cn.ciis.basic.base.BaseCache;
import cn.ciis.basic.base.BaseController;
import cn.ciis.basic.kit.CiisKit;
import cn.ciis.basic.kit.J2CacheKit;
import cn.ciis.basic.model.Equipment;
import cn.ciis.ciis.equipment.EquipmentAdminService;
import cn.ciis.sys.permission.Notes;
import cn.ciis.sys.permission.Remark;
import com.jfinal.aop.Inject;

import java.util.List;

/**
 * 设备实时调试控制层
 */
public class DeviceTestController extends BaseController {

    @Inject
    private EquipmentAdminService equipmentAdminService;

    @Notes(value = "实时调试")
    @Remark(value = "实时调试")
    public void index(){
        List<Equipment> allOnLine = equipmentAdminService.findAllOnLine();
        for (Equipment equipment : allOnLine) {
            equipment.put("bsId", CiisKit.getTioBsId(equipment.getEnterprise(), equipment));
        }

        set("list", allOnLine);

    }

    @Remark(value = "开启调试")
    public void openDebug(String bsId){
        J2CacheKit.set(BaseCache.WS_SESSION_ID_DICTIONARY,bsId+"debug",getLoginAccount().getWebSocketSessionKey());
        kSuccess("调试模式开启成功！");
    }

}
